def solution(a):
    m = None # min sum
    l = len(a)  
    
    for p in range(1,l):
        # print("p", p)
        ab = abs(sum(a[:p])-sum(a[p:l+1]))
        if (m == None):
            m = ab
        if (m > ab):
            m = ab
            
    return m


print(solution([3, 1, 2, 4, 3]))  # 输出: 1
print(solution([1, 1, 3, 3, 2, 1]))  # 输出: 0
print(solution([1000, 1000]))  # 输出: 0
print(solution([1, 2, 3, 4, 5]))  # 输出: 3
print(solution([-1000, 1000]))  # 输出: 2000， 分割后至少为2000


def solution2(a):
    m = 0 # min sum
    l = len(a)  
    
    for p in range(1,l):
        # print("p", p)
        ab = abs(sum(a[:p])-sum(a[p:l+1]))
        if (m == 0):
            m = ab
        if (m > ab):
            m = ab
            
    return m

print(solution2([3, 1, 2, 4, 3]))  # 输出: 1